﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Import Namespace="B2B.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
</asp:Content>



<asp:Content ID="Content3" ContentPlaceHolderID="main_content" runat="server">
    <%
        int maDM = ViewBag.DanhMuc;
    %>


  <div id="divDanhSach" align="center" style="float:left">   
     
        <%
            foreach (var sanpham in (ArrayList)ViewData["listSP_TheoDM"])
            {
                string maSP = ((SP_DanhSachSanPham)sanpham).MaSanPham.ToString();
                string tenSP = ((SP_DanhSachSanPham)sanpham).TenSanPham.ToString();
                string hinhAnh = ((SP_DanhSachSanPham)sanpham).HinhAnh.ToString();
                string url = "../../Images/Alibaba/" + hinhAnh;
                string gia = ((SP_DanhSachSanPham)sanpham).Gia.ToString();
                string soLuongDatToiThieu = ((SP_DanhSachSanPham)sanpham).SoLuongDatToiThieu.ToString();
                string tenDVT = ((SP_DanhSachSanPham)sanpham).TenDVT.ToString();
                 
          %>
            <div class="sanpham">
                <div style="height:5px"><a href="/Product/ProductDetail/<%=maSP %>"> <%=tenSP %> </a></div>
                <div style="height:200px; padding-top:40px"><img src="<%=url %>" width="150px" height="150px" /></div>
                <div>Min oder: <%=soLuongDatToiThieu %><br /> FOB: <%=gia %> / <%=tenDVT %></div>
                <div><a href="/Product/ProductDetail/<%=maSP %>"> <img src="../../Images/contact.png" /> Contact Supplier </a></div>
            </div>
            
          <%} %>

  


  </div>
      <!--Ket61 thuc-->
  <div class="clr"></div>

    <!--Bắt đầu phân trang-->
  <div id="trigger-list">
  <%
      String trang ="";
      int tongtrang = (int)ViewData["tongSP"];
      for (int i = 0; i < tongtrang; i++)
      {          
  %>
         <input type="button"class="trigger error-trigger" value="<%=i +1%>" onclick="layDanhSachPhanTrang(<%=maDM%>,<%=i %>)"/> 
  <%} %>
  </div>
 
  <!--Kết thúc phân trang-->

     <script type="text/javascript">
         function layDanhSachPhanTrang(maDM, page) {
             var s = "";
             var oldPage = 0;
             $.getJSON("/Product/ProductListPhanTrang?maDM=" + maDM +"&page=" + page,
                 function (data) {
                     if (data.length > 0) {
                         for (i = 0; i < data.length; i++) {
                             s += "<div class='sanpham'>";
                             s += " <div style='height:5px'><a href='/Product/ProductDetail/" + data[i].MaSanPham + "'>" + data[i].TenSanPham + "</a></div>"
                             s += " <div style=' height:150px; width:150px; padding-top:40px'><img src='../../Images/Alibaba/" + data[i].HinhAnh + "'width='100px' height='350px'/></div>"
                             s += " <div>Min oder: " + data[i].SoLuongDatToiThieu+ "<br /> FOB: " + data[i].Gia + "/" + data[i].TenDVT+"</div>";
                             s += "</div>";
                         }
                         $("#divDanhSach").html(s);
                     } else
                         $("#divDanhSach").html("");
                 });
             oldPage = page;
         }
         
     </script>

<div class="clr"></div>
 
</asp:Content>
